import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import 'LFormFileUpLogic.dart';
import 'LFormFileUpState.dart';

class LFormFileUpPage extends StatelessWidget {
  const LFormFileUpPage({super.key, required this.tag});
  final String tag;


  @override
  Widget build(BuildContext context) {
    final LFormFileUpState state = Get.find<LFormFileUpLogic>(tag: tag).state;
    return GetBuilder<LFormFileUpLogic>(
        // assignId:true,
        // autoRemove:true,
        tag: tag,
        builder: (logic){
          return Column(
              children: [
                Visibility(
                  visible: state.isShow,
                  child: Align(
                    alignment:Alignment.topLeft,
                    child: Container(
                      margin: const EdgeInsets.only(top: 10),
                      decoration: BoxDecoration(
                          borderRadius: BorderRadius.circular(8),
                          border: Border.all(color: Colors.black26)
                      ),
                      constraints: const BoxConstraints(maxHeight: 60,maxWidth: 60,minHeight: 60,minWidth: 60),
                      child: TextFormField(
                          readOnly: true,
                          textAlign: TextAlign.center,
                          decoration: const InputDecoration(
                            hintText: "+",
                            hintStyle: TextStyle(fontSize: 28,color:Colors.black26),
                            enabledBorder: InputBorder.none,
                            disabledBorder: InputBorder.none,
                            focusedBorder: InputBorder.none,
                            errorBorder: InputBorder.none,
                          ),
                          onTap: (){
                            logic.showCustomModalBottomSheet(context);
                          },
                          onChanged:(v){},
                          onSaved: (v){},
                          validator: (v) {
                            return logic.onValidator();
                          }
                      ),
                    ),
                  ),
                ),

                Container(
                    margin: const EdgeInsets.only(top: 10,bottom: 10),
                    constraints: const BoxConstraints(maxHeight: 200),
                    child: SingleChildScrollView(
                      child: Wrap(
                        alignment: WrapAlignment.start,
                        children: logic.createFileList(context),
                      ),
                    )
                )
              ]
          );
        }
    );
  }

}